home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20010921-20020314 / 000033_bsf@er6.rutgers.edu_Fri Oct 5 15:47:24 EDT 2001.msg < prev    next >
Text File  |  2020-01-01  |  6KB  |  163 lines

  1. Article: 12841 of comp.protocols.kermit.misc
  2. Path: newsmaster.cc.columbia.edu!phl-feed.news.verio.net!iad-peer.news.verio.net!news.verio.net!news.maxwell.syr.edu!lon1-news.nildram.net!195.8.68.195.MISMATCH!newspeer.clara.net!news.clara.net!btnet-peer!btnet!news-feed1.eu.concert.net!att541!ip.att.net!newsmonger.rutgers.edu!news-nb.rutgers.edu!not-for-mail
  3. From: sp2 admin <bsf@er6.rutgers.edu>
  4. Newsgroups: comp.unix.aix,comp.protocols.kermit.misc
  5. Subject: Re: ftp download with help of a file
  6. Date: 5 Oct 2001 19:05:53 GMT
  7. Organization: Rutgers University
  8. Lines: 144
  9. Sender: bsf@er6.rutgers.edu
  10. Message-ID: <9pl0ah$so3$1@newsmonger.rutgers.edu>
  11. References: <5e23bad3.0110050335.3c8e127@posting.google.com> <9pkgfq$ipf$1@newsmaster.cc.columbia.edu>
  12. NNTP-Posting-Host: er6.rutgers.edu
  13. X-Trace: newsmonger.rutgers.edu 1002308753 29443 165.230.180.134 (5 Oct 2001 19:05:53 GMT)
  14. X-Complaints-To: news_support@email.rutgers.edu
  15. NNTP-Posting-Date: 5 Oct 2001 19:05:53 GMT
  16. User-Agent:  tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (SunOS/5.7 (sun4u))
  17. Xref: newsmaster.cc.columbia.edu comp.unix.aix:223822 comp.protocols.kermit.misc:12841
  18.  
  19.  
  20. havent tried it, but from the ftp man page:
  21.   o If a - (hyphen) is specified for the parameter, standard input (stdin) is
  22.     used for read operations and standard output (stdout) is used for write
  23.     operations.
  24.  
  25. as long as you can get your files into stdin, you should be able to do
  26. it that way...
  27.  
  28. In comp.unix.aix Frank da Cruz <fdc@watsun.cc.columbia.edu> wrote:
  29. > In article <5e23bad3.0110050335.3c8e127@posting.google.com>,
  30. > antonio <antonio.napoleone@bedag.ch> wrote:
  31.  
  32. > : We download datfiles for virusengines via ftp. Usually we are doing this
  33. > : automatically, but since a while we are having problems by getting several
  34. > : files in the same remotedirectory with the mget-command.  In some
  35. > : directorys, downloading of those files works fine but in other not.  Now i
  36. > : try to download file by file, but i'm not very experienced in doing this.
  37. > : What i do is getting the FILELIST from the remoteserver and figure out the
  38. > : filenames with help of the grep and awk commands. Now my list looks like
  39. > : this:
  40. > : 
  41. > : AVH32DLL.DL_
  42. > : VIRSIG.DA_
  43. > : VIRINFO.DA_
  44. > : README.TX_
  45. > : 
  46. > : Is it possible to connect to the ftp-host, get each filename from the
  47. > : list, download it and close the connection, after i dowloaded every
  48. > : file, or do i have to connect, get 1 file, close, and so on.
  49. > : 
  50. > This would require a bit more flexibility than you'll find in the regular
  51. > FTP client.  C-Kermit 8.0:
  52.  
  53. >   http://www.columbia.edu/kermit/ck80.html
  54.  
  55. > includes a new scriptable FTP client that will let you do this:
  56.  
  57. >   http://www.columbia.edu/kermit/ftpclient.html
  58.  
  59. > A scripting tutorial is here:
  60.  
  61. >   http://www.columbia.edu/kermit/ckscripts.html
  62.  
  63. > And an FTP-specific scripting tutorial is here:
  64.  
  65. >   http://www.columbia.edu/kermit/ftpscripts.html
  66.  
  67. > And complete documentation is here:
  68.  
  69. >   http://www.columbia.edu/kermit/ckermit3.html#x3
  70.  
  71. > Here is a script that gets the list of filenames:
  72.  
  73. >   cd somelocaldirectory
  74. >   ftp open foo.bar.com /user:myname /password:secret
  75. >   if fail exit 1 Can't reach host
  76. >   if not \v(ftp_loggedin) exit 1 FTP login failed
  77. >   ftp cd blah/blah/somepath
  78. >   if fail exit 1 Directory change failed
  79. >   ftp get /namelist:mylist
  80. >   if fail exit 1 Can't get list of filenames
  81. >   ftp bye  
  82.  
  83. > Obviously we don't recommend putting passwords in scripts; better methods
  84. > are available.  The method shown above was chosen for brevity.  If you
  85. > are using anonymous ftp, the command would be:
  86.  
  87. >   ftp open foo.bar.com /anonymous
  88.  
  89. > Now you have the list of filenames in the local file called 'mylist'.
  90. > At this point, you should consider what you want to do with it.  One
  91. > strategy, as you suggest, is to open a new FTP session for each file.
  92. > This can be done as follows (still in Kermit):
  93.  
  94. >   fopen /read \%c myfile
  95. >   if fail exit 1 Can't open file list
  96. >   while not \f_eof(\%c) {
  97. >       fread /line \%c filename
  98. >       if fail break
  99. >       ftp open foo.bar.com /user:myname /password:secret
  100. >       if fail exit 1 Can't reach host
  101. >       if not \v(ftp_loggedin) exit 1 FTP login failed
  102. >       ftp cd blah/blah/somepath
  103. >       ftp get \m(filename)
  104. >       if fail exit 1 \m(filename): Download failed
  105. >       ftp bye
  106. >   }
  107.  
  108. > This is a sort of brute-force attack, and I'm not sure it does what you
  109. > want anyway.  What happens if a download fails on a particular file?
  110.  
  111. > Here is a more elegant solution:
  112.  
  113. >   cd somelocaldirectory
  114. >   delete *
  115. >   ftp open foo.bar.com /user:myname /password:secret
  116. >   if fail exit 1 Can't reach host
  117. >   if not \v(ftp_loggedin) exit 1 FTP login failed
  118. >   ftp cd blah/blah/somepath
  119. >   if fail exit 1 Directory change failed
  120. >   while true {
  121. >       ftp get /update *      
  122. >       if success break
  123. >   }
  124. >   ftp bye  
  125.  
  126. > Here we clean out any old copies of the files, make the FTP connection to
  127. > the server, cd to the desired server directory, and ask it to send us all
  128. > the files in update mode.  This means: if I already have a current copy of
  129. > a file, don't bother to send it, but if I don't, then please do send it.
  130.  
  131. > If this succeeds, we're done.  If it fails, we try again, automatically
  132. > skipping the files that were sent previously, and so on until all the files
  133. > have been sent.
  134.  
  135. > We can make this script both more robust and more efficient:
  136.  
  137. >   cd somelocaldirectory
  138. >   delete *
  139.  
  140. >   while true {
  141. >       ftp open foo.bar.com /user:myname /password:secret
  142. >       if fail exit 1 Can't reach host
  143. >       if not \v(ftp_loggedin) exit 1 FTP login failed
  144. >       ftp cd blah/blah/somepath
  145. >       if fail exit 1 Directory change failed
  146. >       while true {
  147. >       ftp get /recover /update *      
  148. >       if success goto done
  149. >       if not \v(ftp_connected) break
  150. >       }
  151. >       ftp bye  
  152. >   }
  153. >   done:
  154. >   
  155. > This allows for the case when the connection is lost.  When this happens,
  156. > the script automatically goes back and reestablishes the connection and
  157. > restarts the download; if the connection is not lost, however, it does not
  158. > needlessly break the connection and reestablish it.  In case a long file was
  159. > interrupted in the middle, the /RECOVER option makes the download resume
  160. > from the point of failure.
  161.  
  162. > - Frank
  163.